﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="RN.ERP.Web.Register" %>

<%@ Register Src="UserControl/UCUserRight.ascx" TagName="UCUserRight" TagPrefix="ucUserRight" %>
<%@ Register Src="~/UserControl/UCArea.ascx" TagName="UCArea" TagPrefix="ucArea" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>用户注册</title>
    <link href="Styles/skins/blue/css/style_register.css" type="text/css" rel="stylesheet" />
    <link href="Styles/skins/blue/css/kendo.common.min.css" type="text/css" rel="stylesheet" />
<%--    <link href="Styles/skins/blue/css/kendo.default.min.css" type="text/css" rel="stylesheet" />--%>
        <link href="Styles/skins/blue/css/kendo.blueopal.min.css" type="text/css" rel="stylesheet" />
    <link href="Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" rel="Stylesheet" type="text/css" />
    <script type="text/javascript" src="Scripts/jquery.min.js"></script>
    <script type="text/javascript" src="Scripts/ligerUI/js/ligerui.min.js"></script>
     <script type="text/javascript" language="javascript" src="Scripts/kendo.web.min.js"></script>

     <script type="text/javascript">
         $(document).ready(function () {
             var validator = $("#CorpReg").kendoValidator().data("kendoValidator");
             $("#button").click(function () {
                 if (validator.validate()) {
                     var userName = $("#userName").val();
                     var orgCode = $("#orgCode").val();
                     var corpType = $("#DDLCorpUserType").val();
                     var dogId = $("#hdnDogid").val();
                     $.ajax({
                         async: false,
                         url: "Register.aspx/VerifyCorpReg",
                         data: "{ 'userName':'" + userName + "','orgCode':'" + orgCode + "', 'corpType':'" + corpType + "', 'dogId':'" + dogId + "'}",
                         type: "post",
                         cache: false,
                         contentType: "application/json; charset=utf-8",
                         dataType: "json",
                         success: function (data) {
                             var json = eval('(' + data.d + ')');
                             if (json.status1 == "-1") {
                                 verify = false;
                                 $.ligerDialog.warn('用户名已存在');
                                 return;
                             }
                             if (json.status2 == "-2") {
                                 verify = false;
                                 $.ligerDialog.warn('组织机构代码已存在');
                                 return;
                             }
                             $.ajax({
                                 async: false,
                                 url: "Handlers/RegistryHandler.ashx",
                                 data: $('#CorpReg').serialize(),
                                 type: "post",
                                 cache: false,
                                 success: function (data) {
                                     if (data.result == 1) {
                                         $.ligerDialog.success('注册成功', 300, 150, '提示');
                                         window.location.href("Login.aspx");
                                     }
                                     else {
                                         $.ligerDialog.error('注册失败:' + data.message);
                                     }
                                 }
                             });
                         }
                     });
                 }
             });

             var expvalidator = $("#ExpertReg").kendoValidator({
                 messages: {
                     custom: "无效的身份证号码",
                     required: "请输入身份证号码"
                 },
                 rules: {
                     custom: function (input) {
                         if (input.is("[name=idCard]")) {
                             var value = input.val();
                             var message = "Test";
                             return isIdCardNo(value, message);
                         } else {
                             return true;
                         }
                     }
                 }
             }).data("kendoValidator");

             $("#exbutton").click(function () {
                 if (expvalidator.validate()) {
                     var exMobile = $("#exMobile").val();
                     var idCard = $("#idCard").val();
                     $.ajax({
                         async: false,
                         url: "Register.aspx/VerifyExpertReg",
                         data: "{ 'exMobile':'" + exMobile + "','idCard':'" + idCard + "'}",
                         type: "post",
                         cache: false,
                         contentType: "application/json; charset=utf-8",
                         dataType: "json",
                         success: function (data) {
                             var json = eval('(' + data.d + ')');
                             if (json.status1 == "-1") {
                                 verify = false;
                                 $.ligerDialog.warn('手机号码已存在');
                                 return;
                             }
                             if (json.status2 == "-2") {
                                 verify = false;
                                 $.ligerDialog.warn('身份证号码已存在');
                                 return;
                             }
                             $.ajax({
                                 async: false,
                                 url: "Handlers/RegistryHandler.ashx",
                                 data: $('#ExpertReg').serialize(),
                                 type: "post",
                                 cache: false,
                                 success: function (data) {
                                     if (data.result == 1) {
                                         $.ligerDialog.success('注册成功', 300, 150, '提示');
                                         window.location.href("Login.aspx");
                                     }
                                     else {
                                         $.ligerDialog.error('注册失败:' + data.message);
                                     }
                                 }
                             });
                         }
                     });
                 }
             });
         });

         $(function () {
             $("#back").click(function () {
                 window.location.href = "Login.aspx";
             });
             $("#orgCode").blur(function () {
                 var orgCode = $(this).val().trim();
                 var corpType = $("#DDLCorpUserType").val();
                 if (orgCode != "") {
                     $.getJSON("Handlers/EnterpriseCorpInfoHandler.ashx", { "action": "CheckCorpByOrgCode", "data": orgCode,"roleId":corpType, "rand": Math.random() }, function (data) {
                         if (data.Result) {
                             //组织机构代码已注册
                             $.ligerDialog.confirm(data.Message + '，是否为同一家企业？', GetCorpInofo);
                             return false;
                         }
                         function GetCorpInofo(arg) {
                             if (arg) {
                                 //同一家企业则dogid取已注册企业的dogid
                                 $("#hdnDogid").val(data.Dogid);

                             }
                             else {
                                 $("#orgCode").val("");
                                 $.ligerDialog.error(data.Message + '，不能重复注册');
                                 return false;
                             }
                         }
                     });
                 }
             }
             );
         });

         $(function () {
             $("#exback").click(function () {
                 window.location.href = "Login.aspx";
             });
             $("#exorgCode").blur(function () {
                 var orgCode = $(this).val().trim();
                 if (orgCode != "") {
                     $.getJSON("Handlers/EnterpriseCorpInfoHandler.ashx", { "action": "CheckCorpByOrgCode", "data": orgCode, "rand": Math.random() }, function (data) {
                         if (data.Result) {
                             //组织机构代码已注册
                             $.ligerDialog.confirm(data.Message + '，是否为同一家企业？', GetCorpInofo);
                             return false;
                         }
                         function GetCorpInofo(arg) {
                             if (arg) {
                                 //同一家企业则dogid取已注册企业的dogid
                                 $("#hdnexDogid").val(data.Dogid);
                             }
                             else {
                                 return false;
                             }
                         }
                     });
                 }
             }
             );
         });

         function isIdCardNo(num, message) {
             num = num.toUpperCase();
             //身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X。   
             if (!(/(^\d{15}$)|(^\d{17}([0-9]|X)$)/.test(num))) {
                 message = '输入的身份证号长度不对，或者号码不符合规定！/n15位号码应全为数字，18位号码末位可以为数字或X。';
                 return false;
             }
             //校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。 
             //下面分别分析出生日期和校验位 
             var len, re;
             len = num.length;
             if (len == 15) {
                 re = new RegExp(/^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/);
                 var arrSplit = num.match(re);

                 //检查生日日期是否正确 
                 var dtmBirth = new Date('19' + arrSplit[2] + '/' + arrSplit[3] + '/' + arrSplit[4]);
                 var bGoodDay;
                 bGoodDay = (dtmBirth.getYear() == Number(arrSplit[2])) && ((dtmBirth.getMonth() + 1) == Number(arrSplit[3])) && (dtmBirth.getDate() == Number(arrSplit[4]));
                 if (!bGoodDay) {
                     //alert("输入的身份证号里出生日期不对!");
                     message = '输入的身份证号里出生日期不对！';
                     return false;
                 }
                 else {
                     //将15位身份证转成18位 
                     //校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。 
                     var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
                     var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
                     var nTemp = 0, i;
                     num = num.substr(0, 6) + '19' + num.substr(6, num.length - 6);
                     for (i = 0; i < 17; i++) {
                         nTemp += num.substr(i, 1) * arrInt[i];
                     }
                     num += arrCh[nTemp % 11];
                     return num;
                 }
             }
             if (len == 18) {
                 re = new RegExp(/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/);
                 var arrSplit = num.match(re);

                 //检查生日日期是否正确 
                 var dtmBirth = new Date(arrSplit[2] + "/" + arrSplit[3] + "/" + arrSplit[4]);
                 var bGoodDay;
                 bGoodDay = (dtmBirth.getFullYear() == Number(arrSplit[2])) && ((dtmBirth.getMonth() + 1) == Number(arrSplit[3])) && (dtmBirth.getDate() == Number(arrSplit[4]));
                 if (!bGoodDay) {

                     //alert("输入的身份证号里出生日期不对！");
                     message = '输入的身份证号里出生日期不对！';
                     return false;
                 }
                 else {
                     //检验18位身份证的校验码是否正确。 
                     //校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。 
                     var valnum;
                     var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
                     var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
                     var nTemp = 0, i;
                     for (i = 0; i < 17; i++) {
                         nTemp += num.substr(i, 1) * arrInt[i];
                     }
                     valnum = arrCh[nTemp % 11];
                     if (valnum != num.substr(17, 1)) {
                         message = '18位身份证的校验码不正确！应该为：' + valnum;
                         return false;
                     }
                     return num;
                 }
             }
             return false;
         }
     </script>
     <style type="text/css">
         .k-tool-icon  { margin-top: 0px;}
     </style>
</head>
<body>
    <div class="header">
        <div class="logo">
           <%-- <img src="images/logo_login.jpg" width="804" height="97" alt="" />--%>
         </div>
    </div>
    <!--企业注册-->
            <div>
    <form id="CorpReg" runat="server">
    <div class="content" id="content">
    <input name="action" id="action" type="hidden" value="Corp" />
     <div class="up">
            <img src="images/nrtop.jpg" width="799" height="31" /></div>    
        <div class="libg" >
            <div class="tle">
                企业用户注册</div>
            <div class="con_nr">
                <div class="buzhou">
                    <ul>
                        <li class="li01">
                            <img src="images/h01.jpg" width="142" height="52" alt="" /></li>
                        <li class="li_arrow">
                            <img src="images/arrow01.jpg" width="35" height="24" alt="" /></li>
                        <li class="li02">
                            <img src="images/02.jpg" width="142" height="52" alt="" /></li>
                        <li class="li_arrow">
                            <img src="images/arrow02.jpg" width="35" height="24" /></li>
                        <li class="li03">
                            <img src="images/03.jpg" width="142" height="52" alt="" /></li>
                    </ul>
                    <div class="clear">
                    </div>
                </div>
                <asp:HiddenField ID="hdnDogid" runat="server" />
                <ul >
                    <li class="con_main">
                        <div class="con_l">
                            企业类型</div>
                        <div class="con_r">
                            <div class="qy_type">
                                <span class="qy_type_l"></span><span class="qy_type_r">
<%--                                    <select name="" style="width: 105px; border: 0; overflow: hidden; *border: white;">
                                        <option>-请选择-</option>
                                    </select>--%>
                                    <asp:DropDownList ID="DDLCorpUserType" Width="105px" runat="server" AutoPostBack="false" required validationMessage="请选择企业类型">
                                                </asp:DropDownList>
                                    </span></div>
                            <div class="zuiyou">
                            <span class="k-invalid-msg" data-for="DDLCorpUserType"></span>
                            </div>
                        </div>
                    </li>
                    <li class="con_main">
                        <div class="con_l">
                            企业名称</div>
                        <div class="con_r">
                            <div class="qy_type_kuan">
                                <span class="qy_type_l"></span><span class="qy_type_kuanr">
                                   <input name="corpName" id="corpName" type="text" style="width: 315px" pattern="^[a-zA-Z\u4e00-\u9fa5()（）]+$" required validationMessage="请输入公司名称" data-pattern-msg="只能输入汉字、字母、小括号"/>                                                              
                             </span>
                            </div>
                            <div class="zuiyou">
                              <span class="k-invalid-msg" data-for="corpName"></span>
                            </div>
                        </div>
                    </li>
                    <li class="con_main">
                        <div class="con_l">
                            所有权性质</div>
                        <div class="con_r">
                            <div class="qy_type">
                                <span class="qy_type_l"></span><span class="qy_type_r">
<%--                                    <select name="" style="width: 105px">
                                        <option>-请选择-</option>
                                    </select>--%>
                            <asp:DropDownList ID="DDlCorpType" Width="105px" runat="server" required validationMessage="请选择所有权性质">
                            </asp:DropDownList>                                   
                                    </span>
                            </div>
                            <div class="zuiyou">
                            <span class="k-invalid-msg" data-for="DDlCorpType"></span>
                            </div>
                        </div>
                    </li>
                    <li class="con_main">
                        <div class="con_l">
                            组织机构代码</div>
                        <div class="con_r">
                            <div class="qy_usual">
                                <span class="qy_type_l"></span><span class="qy_usual_r">
                                    <input name="orgCode" id="orgCode" type="text" style="width: 275px" pattern="\d{8}[-][\d|X]" required validationMessage="请输入组织机构代码"  data-pattern-msg="无效的组织机构代码"/></span>
                            </div>
                            <div class="zuiyou">
                             <span class="k-invalid-msg" data-for="orgCode"></span>
                            </div>
                        </div>
                    </li>
                    <li class="con_main">
                        <div class="con_l">
                            营业执照字号</div>
                        <div class="con_r" id="test">
                            <div class="qy_usual">
                                <span class="qy_type_l"></span><span class="qy_usual_r">
                                    <input name="bussinessNum" id="bussinessNum"  type="text" style="width: 275px" pattern="^[0-9]*$" required validationMessage="请输入营业执照号码"  data-pattern-msg="无效的营业执照号码" /></span>
                            </div>
                            <div class="zuiyou">
                              <span class="k-invalid-msg" data-for="bussinessNum"></span>
                            </div>
                        </div>
                    </li>
                    <li class="con_main">
                        <div class="con_l">
                            请输入你的用户名</div>
                        <div class="con_r">
                            <div class="qy_usual">
                                <span class="qy_type_l"></span><span class="qy_usual_r">
                                    <input name="userName" id="userName" type="text" style="width: 275px" required validationMessage="请输入用户名"/></span>
                            </div>
                            <div class="zuiyou">
                           <span class="k-invalid-msg" data-for="userName"></span>
                            </div>
                        </div>
                    </li>
                    <li class="con_main">
                        <div class="con_l">
                            设定一个密码</div>
                        <div class="con_r">
                            <div class="qy_usual">
                                <span class="qy_type_l"></span><span class="qy_usual_r">
                                    <input name="passWord" type="passWord" style="width: 275px" required validationMessage="请输入密码" /></span>
                            </div>
                            <div class="zuiyou">
                            <span class="k-invalid-msg" data-for="passWord"></span>
                            </div>
                        </div>
                    </li>
                    <li class="con_main">
                        <div class="con_l">
                            请再次输入密码确认</div>
                        <div class="con_r">
                            <div class="qy_usual">
                                <span class="qy_type_l"></span><span class="qy_usual_r">
                                    <input name="passwordR" id="passwordR" type="password" style="width: 275px" required validationMessage="请再次输入密码"/></span>
                            </div>
                            <div class="zuiyou">
                             <span class="k-invalid-msg" data-for="passwordR"></span>
                            </div>
                        </div>
                    </li>
                    <li class="con_main">
                        <div class="con_l">
                            企业注册地</div>
                        <div class="con_r">
                            <div class="qy_usual"><ucArea:ucArea ID="ucArea" Name="ucArea" runat="server" />
                                </div>
                            <div class="zuiyou">
                            </div>
                        </div>
                    </li>
                    <li class="con_main">
                        <div class="con_l">
                            电子邮箱地址</div>
                        <div class="con_r">
                            <div class="qy_usual">
                                <span class="qy_type_l"></span><span class="qy_usual_r">
                                    <input name="email" id="email" type="email" style="width: 275px;" required validationMessage="请输入邮箱地址" data-email-msg="邮箱格式无效"/></span>
                            </div>
                            <div class="zuiyou">
                             <span class="k-invalid-msg" data-for="email"></span>
                            </div>
                        </div>
                    </li>
                    <li class="con_main">
                        <div class="con_l">
                            联系电话</div>
                        <div class="con_r">
                            <div class="qy_usual">
                                <span class="qy_type_l"></span><span class="qy_usual_r">
                                    <input name="linkTel" id="linkTel" type="text" style="width: 275px;" pattern="(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$" required validationMessage="请输入联系电话"  data-pattern-msg="无效的联系号码" /></span>
                            </div>
                            <div class="zuiyou">
                            <span class="k-invalid-msg" data-for="linkTel"></span>
                            </div>
                        </div>
                    </li>
                </ul>
                <div class="zhuyi">
                    <div class="con_l">
                    </div>
                    <div class="zhuyi_nr">
                        <h2>
                            注册网站用户，需认真填写上表:</h2>
                        用户要自觉遵守国家有关法律、法规，遵守网上道德，对于发布违法、不健康或不真实信息的用户，本站有权删除其所有发布信息，并拒绝其使用该用户名。</div>
                    <div class="clear">
                    </div>
                </div>
                <div class="zhuyi">
                    <div class="con_l">
                    </div>
                    <div class="tongyi" style="padding-top: 4px;">
                        <input name="checkbox" type="checkbox" value="name" checked="checked" required validationMessage="请接受服务条款"  />我已阅读上述注意事项，同意并接受该事项！</div>
                        <span align="center"class="k-invalid-msg" data-for="checkbox"></span>
                    <div class="clear">
                      
                    </div>
                </div>
                <div class="zhuyi">
                    <div class="con_l">
                    </div>
                    <div class="zhuce">
                        <a href="javascript:void(0);">
<%--                      <input id="button" name="button" type="button" src="images/zhuceicon.jpg" width="242" height="54"  />--%>
                           <img id="button" name="button" src="images/zhuceicon.jpg" width="242" height="54"  />
<%--                          <input id="button" name="button" type="button" value="注册"/>--%>

                           </a>
                                                 
                        </div>
                      <div class="goback">

                      <img id="back" name="back" src="images/back.jpg" alt=""width="102" height="54"  />
                    </div>
                    <div class="clear">
                    </div>
                </div>
                <div class="clear">
                </div>
               
            </div>
            <div>
                <img src="images/foot01.jpg" width="700" height="6" /></div>
        </div>
        </div>
                <telerik:RadScriptManager ID="RadScriptManager1" runat="server">      
    </telerik:RadScriptManager>
            </form>
            </div>


    
        <ucUserRight:UCUserRight ID="UCUserRight1" runat="server" />
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="WebBlue">
        </telerik:RadWindowManager>
</body>
</html>
